package com.duck.communication.service.impl;

import com.duck.communication.dao.QuestionDao;
import com.duck.communication.domain.vo.ExpertInfoVo;
import com.duck.communication.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private QuestionDao questionDao;
    @Override
    public Integer DirectedQuestion(HashMap<String, Object> question) {
        return questionDao.addDirectedQuestion(question);
    }

    @Override
    public Integer PublicQuestion(HashMap<String, Object> question) {
        return questionDao.addPublicQuestion(question);
    }

    @Override
    public List<HashMap<String, Object>> searchMyQuestion(String userId) {
        return questionDao.searchAllByFarmerId(userId);
    }

    @Override
    public List<HashMap<String, Object>> searchAllQuestions() {
        return questionDao.searchAllQuestions();
    }

    @Override
    public List<HashMap<String, Object>> searchDirectedQuestion(String userId) {
        return questionDao.searchAllByExpertId(userId);
    }

    @Override
    public Integer answerQuestion(HashMap<String, Object> answer) {
        return questionDao.addAnswer(answer);
    }

    @Override
    public List<HashMap<String, Object>> searchExpertAnsweredQuestion(String userId) {
        return questionDao.searchExpertAnsweredQuestion(userId);
    }

    @Override
    public List<HashMap<String, Object>> searchDirectedUnAnswer(String userId) {
        return questionDao.searchDirectedUnAnswer(userId);
    }

    @Override
    public List<HashMap<String, Object>> searchAllAnsweredQuestion() {
        return questionDao.searchAllAnsweredQuestion();
    }

    @Override
    public ExpertInfoVo searchExpertAnswerNumberAndAcceptedNumber(String userId) {
        return questionDao.searchExpertAnswerNumberAndAcceptedNumber(userId);
    }

    @Override
    public Integer addAcceptedAnswer(Integer answerId) {
        return questionDao.updateAcceptedAnswer(answerId);
    }

    @Override
    public Integer updateIsAnswer(Integer postId) {
        return questionDao.updateIsAnswer(postId);
    }

    @Override
    public List<HashMap<String,Object>> searchQuestion(String questionId) {
        return questionDao.searchQuestion(questionId);
    }

    @Override
    public List<HashMap<String, Object>> searchUnAnsweredQuestion() {
        return questionDao.searchUnAnsweredQuestion();
    }

    @Override
    public List<HashMap<String, Object>> searchAllPublicQuestion() {
        return questionDao.searchAllPublicQuestion();
    }

    @Override
    public List<HashMap<String, Object>> searchAllPublicAnsweredQuestion() {
        return questionDao.searchAllPublicAnsweredQuestion();
    }

    @Override
    public List<HashMap<String, Object>> searchAllPublicUnAnsweredQuestion() {
        return questionDao.searchAllPublicUnAnsweredQuestion();
    }
}
